Dynomotion

Group: DynoMotion Message: 14219 From: kn6za Date: 12/5/2016
Subject: CSSJOG.C problem with css x_off

Hi,


 I am having a problem with CSSJOG.C


   The *css_xoff is, as I understand it, the x axis tool offset.


    It looks to me like this is not being set, and is always 0 as reported in console by the printf line at the end of this file.


   The CSS is working, but it is working relative to the machine 0, no x axis tool offset is being applied. I doubt the problem is with CSSJOG.c, but I am at a loss to figure out how to trouble shoot the x axis offset not being set.



   Thanks for any help on this one. This file is unedited straight from the install directory.


   Andrew



// Handle CSS (Constant Surface Speed) messages from KMotionCNC)

//

// This code assumes you have an Axis Channel Configured to control

// Spindle speed and Jog Calls can be made to control speed

//

// Include this function into your main Init Thead code and call it

// continuously from a forever loop similar to that shown here

 

//#include "KMotionDef.h"

//#include "MySpindleDefs.h"

//#include "CSSJog.c"

//main()

//{

// for (;;)

// {

// WaitNextTimeSlice();

// ServiceCSS();

// }

//}


int   *css_mode = &persist.UserData[PC_COMM_CSS_MODE]; // Mode 1=Normal RPM mode. 2=CSS

float *css_xoff = &persist.UserData[PC_COMM_CSS_X_OFFSET]; // X axis counts for Radius zero

float *css_xfactor = &persist.UserData[PC_COMM_CSS_X_FACTOR]; // X axis factor to convert counts to inches 

float *css_s = &persist.UserData[PC_COMM_CSS_S]; // S speed setting in inches/sec

float *css_max_rpm = &persist.UserData[PC_COMM_CSS_MAX_RPM]; // Limit max RPM to this value as Radius approaches zero


double css_T=0;  // update only every so often

#define CSS_UPDATE_DT 0.05


void ServiceCSS(void)

{

float rpm;

double T=Time_sec();


if (*css_mode == 2 && T > css_T) // check if we are in CSS mode and it is time to update

{

css_T=T+CSS_UPDATE_DT;  // determine next time to update

// convert axis position to distance from center in inches

float radius = fast_fabs((chan[CS0_axis_x].Dest - *css_xoff) * *css_xfactor);

if (radius > 0.0f)

rpm = *css_s / (radius * (TWO_PI_F/60.0f));

else

rpm = *css_max_rpm;


if (rpm > *css_max_rpm) rpm = *css_max_rpm;

if (persist.UserData[STATEVAR]!=0)  // if spindle is already on, ramp to new speed

{

if (USE_POS_NEG_VOLTAGE)

Jog(SPINDLEAXIS,rpm * FACTOR * persist.UserData[STATEVAR]);

else

Jog(SPINDLEAXIS,rpm * FACTOR);

}

printf("xoff=%f radius= %f xfactor=%f s=%f(ips) maxrpm=%f rpm=%f\n",*css_xoff,radius,*css_xfactor,*css_s,*css_max_rpm,rpm);

}

}


 

Group: DynoMotion Message: 14222 From: Tom Kerekes Date: 12/5/2016
Subject: Re: CSSJOG.C problem with css x_off

Hi Andrew,

>>>>>>The *css_xoff is, as I understand

it, the x axis tool offset.

Basically yes - but includes any Fixture or G92 offsets.

Are you entering an X offset for the Tool (not the Length)?

Are you enabling Tool Length Compensation with HxxxG43?

What does the X DRO read?  Proper radius or Machine position?

What Version of KMotion are you running?

What is printed to the Console?  Note you should add a Delay_sec(1); before the printf to avoid flooding the Console with messages.

Regards

TK


On 12/5/2016 4:47 PM, kn6za@... [DynoMotion] wrote:
 

Hi,


 I am having a problem with CSSJOG.C


   The *css_xoff is, as I understand it, the x axis tool offset.


    It looks to me like this is not being set, and is always 0 as reported in console by the printf line at the end of this file.


   The CSS is working, but it is working relative to the machine 0, no x axis tool offset is being applied. I doubt the problem is with CSSJOG.c, but I am at a loss to figure out how to trouble shoot the x axis offset not being set.



   Thanks for any help on this one. This file is unedited straight from the install directory.


   Andrew



// Handle CSS (Constant Surface Speed) messages from KMotionCNC)

//

// This code assumes you have an Axis Channel Configured to control

// Spindle speed and Jog Calls can be made to control speed

//

// Include this function into your main Init Thead code and call it

// continuously from a forever loop similar to that shown here

 

//#include "KMotionDef.h"

//#include "MySpindleDefs.h"

//#include "CSSJog.c"

//main()

//{

// for (;;)

// {

// WaitNextTimeSlice();

// ServiceCSS();

// }

//}


int   *css_mode = &persist.UserData[PC_COMM_CSS_MODE]; // Mode 1=Normal RPM mode. 2=CSS

float *css_xoff = &persist.UserData[PC_COMM_CSS_X_OFFSET]; // X axis counts for Radius zero

float *css_xfactor = &persist.UserData[PC_COMM_CSS_X_FACTOR]; // X axis factor to convert counts to inches 

float *css_s = &persist.UserData[PC_COMM_CSS_S]; // S speed setting in inches/sec

float *css_max_rpm = &persist.UserData[PC_COMM_CSS_MAX_RPM]; // Limit max RPM to this value as Radius approaches zero


double css_T=0;  // update only every so often

#define CSS_UPDATE_DT 0.05


void ServiceCSS(void)

{

float rpm;

double T=Time_sec();


if (*css_mode == 2 && T > css_T) // check if we are in CSS mode and it is time to update

{

css_T=T+CSS_UPDATE_DT;  // determine next time to update

// convert axis position to distance from center in inches

float radius = fast_fabs((chan[CS0_axis_x].Dest - *css_xoff) * *css_xfactor);

if (radius > 0.0f)

rpm = *css_s / (radius * (TWO_PI_F/60.0f));

else

rpm = *css_max_rpm;


if (rpm > *css_max_rpm) rpm = *css_max_rpm;

if (persist.UserData[STATEVAR]!=0)  // if spindle is already on, ramp to new speed

{

if (USE_POS_NEG_VOLTAGE)

Jog(SPINDLEAXIS,rpm * FACTOR * persist.UserData[STATEVAR]);

else

Jog(SPINDLEAXIS,rpm * FACTOR);

}

printf("xoff=%f radius= %f xfactor=%f s=%f(ips) maxrpm=%f rpm=%f\n",*css_xoff,radius,*css_xfactor,*css_s,*css_max_rpm,rpm);

}

}


 


Group: DynoMotion Message: 14223 From: kn6za Date: 12/5/2016
Subject: Re: CSSJOG.C problem with css x_off
Yes, x offset for the tool is entered.

Yes the G43 Hxx is active and the green DRO is reading correctly as 3.174" radius.

As i move the axis, the CSS varies the rpm, but the rpm gets faster as I aproach machine coord 0. regardless of tool offset.

if I swich the DRO to the red color machine coord readout, then the rpm mathces that position @ 1.406647

I am running 4.33

The console reads out 

xoff=0.000000 radius= 1.406647 xfactor=0.000012 s=400.000397(ips) rpm=2715.480469 maxrpm=3500.000000

It seems as though its not picking up the x axis offset for some reason. everything else looks right as far as I can tell.


Group: DynoMotion Message: 14224 From: Tom Kerekes Date: 12/5/2016
Subject: Re: CSSJOG.C problem with css x_off

Hmmm,  I can't see a problem here.  I get:

xoff=40000.000000 radius= 1.886907 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=529.968994
xoff=40000.000000 radius= 1.739223 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=574.970703
xoff=40000.000000 radius= 1.591565 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=628.313599
xoff=40000.000000 radius= 1.443882 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=692.579163
xoff=40000.000000 radius= 1.296198 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=771.489075
xoff=40000.000000 radius= 1.148514 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=870.692566
xoff=40000.000000 radius= 1.000830 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=999.173340
xoff=40000.000000 radius= 0.853146 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=1172.135620
xoff=40000.000000 radius= 0.705462 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=1417.514893
xoff=40000.000000 radius= 0.557778 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=1792.833496
xoff=40000.000000 radius= 0.410094 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=2438.473633
xoff=40000.000000 radius= 0.262410 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=2500.000000
xoff=40000.000000 radius= 0.114726 xfactor=0.000050 s=104.719994(ips) maxrpm=2500.000000 rpm=2500.000000

The X Offset is passed in Persist Variable 111

#define PC_COMM_CSS_X_OFFSET 111    // X axis counts for Radius zero

Do you have anything else using that variable?

Regards
TK




On 12/5/2016 8:21 PM, kn6za@... [DynoMotion] wrote:
 

Yes, x offset for the tool is entered.


Yes the G43 Hxx is active and the green DRO is reading correctly as 3.174" radius.

As i move the axis, the CSS varies the rpm, but the rpm gets faster as I aproach machine coord 0. regardless of tool offset.

if I swich the DRO to the red color machine coord readout, then the rpm mathces that position @ 1.406647

I am running 4.33

The console reads out 

xoff=0.000000 radius= 1.406647 xfactor=0.000012 s=400.000397(ips) rpm=2715.480469 maxrpm=3500.000000

It seems as though its not picking up the x axis offset for some reason. everything else looks right as far as I can tell.



Group: DynoMotion Message: 14225 From: kn6za Date: 12/5/2016
Subject: Re: CSSJOG.C problem with css x_off
I cant find anything using variable 111

Were is it established that 

#define PC_COMM_CSS_X_OFFSET 111    // X axis counts for Radius zero

Perhaps I changed this in error.

Group: DynoMotion Message: 14226 From: Tom Kerekes Date: 12/5/2016
Subject: Re: CSSJOG.C problem with css x_off

It is defined in PC_DSP.h.   Do you have Visual Studio?  Are you recompiling the Libraries?

You might try manually viewing the variable and manually setting it to determine whether it is never being set or whether it isn't being read.  You can use Console commands:

GetPersistHex111
SetPersistHex111 476A6000

476A6000 is a hexadecimal representation of floating point 60000.0 counts.

The G96 should cause the variables to be written.  The Offset must be in effect when G96 is executed.

Regards
TK


On 12/5/2016 8:50 PM, kn6za@... [DynoMotion] wrote:
 
I cant find anything using variable 111

Were is it established that 

#define PC_COMM_CSS_X_OFFSET 111    // X axis counts for Radius zero

Perhaps I changed this in error.


Group: DynoMotion Message: 14227 From: kn6za Date: 12/5/2016
Subject: Re: CSSJOG.C problem with css x_off
I found #define PC_COMM_CSS_X_OFFSET 111

in DSP_KFLOP/ PC_DSP.h

and I changed it from 111 to 109, just to see what happens, and no change, then put it back to 111.

  I will try the console command.

  Ok, GetPersistHex111 resulted in 0

 SetPersistHex111 476A6000 was successfull

 GetPersistHex111 then resulted in 476a600

 now I start the spindle and 111 is back to 0
 
 
 
Group: DynoMotion Message: 14228 From: kn6za Date: 12/5/2016
Subject: Re: CSSJOG.C problem with css x_off
I'll shut down and restart in the am, perhaps it just needs a 3 finger salute.
Group: DynoMotion Message: 14229 From: kn6za Date: 12/6/2016
Subject: Re: CSSJOG.C problem with css x_off
Hi Tom,

Sorry for all the trouble, power cycle fixed it up just fine. Have no idea why it had that problem but it is gone now.

Thanks for the help!
Group: DynoMotion Message: 14230 From: Tom Kerekes Date: 12/6/2016
Subject: Re: CSSJOG.C problem with css x_off

Thanks for posting back.  Strange.  If you ever determine what causes the problem please let us know.

Regards

TK


On 12/6/2016 5:09 AM, kn6za@... [DynoMotion] wrote:
 

Hi Tom,

Sorry for all the trouble, power cycle fixed it up just fine. Have no idea why it had that problem but it is gone now.

Thanks for the help!


Group: DynoMotion Message: 14237 From: kn6za Date: 12/6/2016
Subject: Re: CSSJOG.C problem with css x_off
Will do!